﻿
Partial Class Mantenimientos_frmMantenimientoClasificacion
    Inherits System.Web.UI.Page

    '    Private oDvClasificacion As DataView
    '    Private oConfig As New AppSettingsReader

    '    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '        'Introducir aquí el código de usuario para inicializar la página
    '        Try
    '            Me.lblMensaje.Text = ""
    '            If Not Session("dvw_Clasificacion") Is Nothing Then
    '                oDvClasificacion = Session("dvw_Clasificacion")
    '            End If
    '            If Not Page.IsPostBack Then
    '                Session.Timeout = 1000
    '                fnCargarComboCompania()
    '                fnInhabilitarHabilitarRdbuttons(False)
    '                fnInhabilitarHabilitarControles(False)
    '                Me.hidCompania.Value = Me.ddlCompania.SelectedItem.Text
    '                fnCargarClasificacion()
    '            End If
    '            fnCargarEventos()
    '        Catch ex As Exception
    '            lblMensaje.Text = C_MSG_ERROR_INESPERADO
    '            CreateLogFiles()
    '            ErrorLog(Server.MapPath("Logs/ErrorLog"), ex.Message + " " + ex.StackTrace)

    '        End Try
    '    End Sub

    '    Private Sub fnCargarEventos()
    '        Me.ddlTipoCompra.Attributes.Add("onchange", "return fnLimpiarTipoCompra();")
    '        Me.chkConcepto.Attributes.Add("onclick", "fnHabilitarDeshabilitarGrupoTecnico();")
    '        Me.txtComprador.Attributes.Add("readonly", "readonly")
    '        Me.txtAprobador.Attributes.Add("readonly", "readonly")
    '    End Sub

    '    Private Sub dtgGrilla_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dtgGrilla.ItemCreated
    '        Try
    '            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
    '                e.Item.Attributes.Add("onmouseover", "bkAnterior=this.style.backgroundColor; this.style.backgroundColor='beige';this.style.cursor='hand'")
    '                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=bkAnterior;")
    '                NetFrameworkNameControl(e, "0")
    '            End If
    '        Catch ex As Exception
    '            lblMensaje.Text = C_MSG_ERROR_INESPERADO
    '            CreateLogFiles()
    '            ErrorLog(Server.MapPath("Logs/ErrorLog"), ex.Message + " " + ex.StackTrace)

    '        End Try
    '    End Sub

    '    Private Sub fnCargarComboCompania()
    '        Try
    '            Dim oCompania As New srvNegCompania.srvNegCompania
    '            Dim ds As DataSet
    '            Dim sError As String
    '            Dim bOk As Boolean
    '            bOk = oCompania.Listar(1, 0, ds, sError)
    '            If Not bOk Then
    '                Me.lblMensaje.Text = sError
    '            Else

    '            End If
    '            Me.ddlCompania.DataSource = ds
    '            ddlCompania.DataTextField = "DESCRIPCION"
    '            ddlCompania.DataValueField = "COMPANIA"
    '            ddlCompania.DataBind()
    '        Catch ex As Exception
    '            lblMensaje.Text = C_MSG_ERROR_INESPERADO
    '            CreateLogFiles()
    '            ErrorLog(Server.MapPath("Logs/ErrorLog"), ex.Message + ex.StackTrace)
    '        End Try
    '    End Sub

    '    Private Sub rdbCompradorNo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbCompradorNo.CheckedChanged
    '        fnInhabilitarHabilitarComprador(False)
    '    End Sub

    '    Private Sub rdbCompradorSi_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbCompradorSi.CheckedChanged
    '        fnInhabilitarHabilitarComprador(True)
    '    End Sub

    '    Private Sub rdbAprobadorNo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbAprobadorNo.CheckedChanged
    '        fnInhabilitarHabilitarControlesAprobacion(False)
    '    End Sub

    '    Private Sub rdbAprobadorSi_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbAprobadorSi.CheckedChanged
    '        fnInhabilitarHabilitarControlesAprobacion(True)
    '    End Sub


    '    Private Sub fnCargarClasificacion()
    '        Try
    '            Dim psClasificacion As String
    '            Dim psDescripcion As String
    '            If Not (txtClasificacion.Text.Trim.Equals(String.Empty)) Then
    '                psClasificacion = txtClasificacion.Text.Trim
    '            Else
    '                psClasificacion = ""
    '            End If
    '            If Not (txtDescripcion.Text.Trim.Equals(String.Empty)) Then
    '                psDescripcion = txtDescripcion.Text.Trim
    '            Else
    '                psDescripcion = ""
    '            End If
    '            oDvClasificacion = fnCargarDataSet(psClasificacion, psDescripcion).Tables(0).DefaultView
    '            Session("dvw_Clasificacion") = oDvClasificacion
    '            EnlazarDatagrid(Me.dtgGrilla, oDvClasificacion)
    '        Catch ex As Exception
    '            lblMensaje.Text = C_MSG_ERROR_INESPERADO
    '            CreateLogFiles()
    '            ErrorLog(Server.MapPath("Logs/ErrorLog"), ex.Message + ex.StackTrace)
    '        End Try
    '    End Sub

    '    Public Function fnCargarDataSet(ByVal psClasificacion As String, ByVal psDescripcion As String) As DataSet
    '        Dim oDs As New DataSet
    '        Dim sError As String
    '        Dim bOk As Boolean

    '        Dim oNegClasificacion As New srvNegClasificacion.srvNegClasificacion

    '        bOk = oNegClasificacion.fnListar(2, hidCompania.Value, psClasificacion, psDescripcion, oDs, sError)
    '        If Not bOk Then
    '            lblMensaje.Text = sError
    '        End If
    '        Return oDs
    '    End Function


    '    Private Sub fnInhabilitarHabilitarRdbuttons(ByVal valor As Boolean)
    '        Me.rdbAprobadorNo.Enabled = valor
    '        Me.rdbAprobadorSi.Enabled = valor
    '        Me.rdbCompradorNo.Enabled = valor
    '        Me.rdbCompradorSi.Enabled = valor
    '    End Sub


    '    Private Sub fnInhabilitarHabilitarControlesAprobacion(ByVal valor As Boolean)
    '        Me.rdbAprobadorNo.Checked = Not valor

    '        Me.chkConcepto.Enabled = valor
    '        If valor = False Then
    '            Me.txtAprobador.Text = ""
    '        Else
    '            Me.rdbAprobadorSi.Checked = valor
    '        End If
    '    End Sub
    '    Private Sub fnInhabilitarHabilitarComprador(ByVal valor As Boolean)
    '        Me.rdbCompradorNo.Checked = Not valor
    '        Me.ddlTipoCompra.Enabled = valor
    '        If valor = False Then
    '            Me.txtComprador.Text = ""
    '        Else
    '            Me.rdbCompradorSi.Checked = valor
    '        End If
    '    End Sub

    '    Private Sub fnInhabilitarHabilitarControles(ByVal valor As Boolean)
    '        fnInhabilitarHabilitarControlesAprobacion(valor)
    '        fnInhabilitarHabilitarComprador(valor)
    '    End Sub

    '    Private Sub fnCargaDatosFila()
    '        fnInhabilitarHabilitarControles(True)
    '        Me.hidClasificacion.Value = oDvClasificacion.Item(Me.dtgGrilla.SelectedIndex())("CLASIFICACION")

    '        If "REGIONAL" = oDvClasificacion.Item(Me.dtgGrilla.SelectedIndex())("TIPO_COMPRA") Then
    '            Me.ddlTipoCompra.SelectedIndex = 1
    '        Else
    '            Me.ddlTipoCompra.SelectedIndex = 0
    '        End If
    '        Me.txtComprador.Text = oDvClasificacion.Item(Me.dtgGrilla.SelectedIndex())("COMPRADOR_PROCESO")

    '        Me.txtAprobador.Text = oDvClasificacion.Item(Me.dtgGrilla.SelectedIndex())("GRUPO_TECNICO")
    '        If oDvClasificacion.Item(Me.dtgGrilla.SelectedIndex())("CONCEPTO_TECNICO") = "SI" Then
    '            Me.chkConcepto.Checked = True
    '        Else
    '            Me.chkConcepto.Checked = False
    '        End If


    '    End Sub
    '    Private Sub fnPrepararFilaSeleccionada()

    '        Dim txtAreaAprobTecnica_onKeyUp As String = _
    '                      String.Format("javascript:return MostrarDetalleRecipienteAprobador('{0}','{1}',{2},'{3}','{4}')", Me.txtAprobador.ClientID, "3", 1, oConfig.GetValue("filtroAprobadorTecnico", GetType(System.String)), Me.hidCompania.Value)
    '        txtAprobador.Attributes.Add("onKeyUp", txtAreaAprobTecnica_onKeyUp)
    '        txtAprobador.Attributes.Add("onDblClick", txtAreaAprobTecnica_onKeyUp)

    '        Dim txtComprador_onKeyUp As String = _
    '             String.Format("javascript:MostrarDetalleRecipienteComprador('{0}','{1}',{2},'{3}','{4}')", txtComprador.ClientID, "3", 1, oConfig.GetValue("filtroComprador", GetType(System.String)), Me.hidCompania.Value)
    '        txtComprador.Attributes.Add("onKeyUp", txtComprador_onKeyUp)
    '        txtComprador.Attributes.Add("onDblClick", txtComprador_onKeyUp)

    '        fnInhabilitarHabilitarRdbuttons(True)

    '    End Sub

    '    Private Sub dtgGrilla_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtgGrilla.SelectedIndexChanged
    '        Try
    '            dtgGrilla.SelectedItem.Attributes.Item("onmouseover") = "this.style.cursor='hand'"
    '            dtgGrilla.SelectedItem.Attributes.Remove("onmouseout")
    '            fnCargaDatosFila()
    '            fnPrepararFilaSeleccionada()
    '        Catch ex As Exception
    '            lblMensaje.Text = C_MSG_ERROR_INESPERADO
    '            CreateLogFiles()
    '            ErrorLog(Server.MapPath("Logs/ErrorLog"), ex.Message + " " + ex.StackTrace)

    '        End Try
    '    End Sub

    '    Private Function fnValidarGuardar(ByRef tipo As Integer) As Boolean
    '        Dim valor As Boolean = True

    '        If Me.rdbAprobadorSi.Checked Then
    '            If Me.chkConcepto.Checked = True And Me.txtAprobador.Text.Trim = "" Then
    '                Me.lblMensaje.Text = "Debe ingresar un Aprobador Técnico ya que el Concepto Técnico está habilitado."
    '                valor = False
    '            End If
    '        End If

    '        If valor And Me.rdbCompradorSi.Checked Then
    '            If Me.txtComprador.Text.Trim = "" Then
    '                Me.lblMensaje.Text = "Debe ingresar un Comprador."
    '                valor = False
    '            End If
    '        End If

    '        If valor Then
    '            If Me.rdbAprobadorSi.Checked And Me.rdbCompradorSi.Checked Then
    '                tipo = 1
    '            ElseIf Me.rdbAprobadorSi.Checked Then
    '                tipo = 3
    '            ElseIf Me.rdbCompradorSi.Checked Then
    '                tipo = 2
    '            Else
    '                Me.lblMensaje.Text = "Debe habilitar  Modificar Compradores y/o Aprobadores Técnicos antes de guardar."
    '                valor = False
    '            End If
    '        End If

    '        Return valor
    '    End Function


    '    Private Sub imgGuardar_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgGuardar.Click
    '        If Me.dtgGrilla.SelectedIndex <> -1 Then
    '            If Not Page.IsValid Then
    '                Exit Sub
    '            End If
    '            Dim bOk As Boolean = False
    '            Dim sError As String
    '            Dim tipo As Integer
    '            If fnValidarGuardar(tipo) Then
    '                Dim oNegClasificacion As New srvNegClasificacion.srvNegClasificacion
    '                If Not oNegClasificacion.fnActualizar(tipo, Me.hidCompania.Value, Me.hidClasificacion.Value, IIf(Me.chkConcepto.Checked, "1", "0"), Me.ddlTipoCompra.SelectedItem.Text, Me.txtComprador.Text.Trim, Me.txtAprobador.Text.Trim, sError) Then
    '                    lblMensaje.Text = C_MSG_ERROR_INESPERADO
    '                    CreateLogFiles()
    '                    ErrorLog(Server.MapPath("Logs/ErrorLog"), sError)
    '                End If
    '                fnCargarClasificacion()
    '            End If

    '        Else
    '            Me.lblMensaje.Text = "Debe existir alguna fila en edición"
    '        End If
    '    End Sub

    '    Private Sub imgBuscar_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBuscar.Click
    '        fnCargarClasificacion()
    '        Me.dtgGrilla.SelectedIndex = -1
    '        fnInhabilitarHabilitarRdbuttons(False)
    '        fnInhabilitarHabilitarControles(False)
    '    End Sub

    '    Private Sub ddlCompania_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCompania.SelectedIndexChanged
    '        fnInhabilitarHabilitarRdbuttons(False)
    '        fnInhabilitarHabilitarControles(False)
    '        Me.hidCompania.Value = Me.ddlCompania.SelectedItem.Text
    '        fnCargarClasificacion()
    '    End Sub
End Class
